package com.jw.qme.controller;

import cn.dev33.satoken.stp.StpUtil;
import cn.dev33.satoken.util.SaResult;
import com.jw.qme.domain.dto.ChatConversationDTO;
import com.jw.qme.service.ChatConversationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/chat-conversation")
public class ChatConversationController {

    @Autowired
    private ChatConversationService chatConversationService;

    /**
     * 创建对话框
     * @param chatConversationDTO
     * @return
     */
    @PostMapping("/create")
    public SaResult create(@RequestBody ChatConversationDTO chatConversationDTO) {
        chatConversationDTO.setUserId((String)StpUtil.getLoginId());
        return SaResult.data(chatConversationService.create(chatConversationDTO));
    }

    /**
     * 删除对话框
     * @param chatConversationDTO
     * @return
     */
    @PostMapping("/delete")
    public SaResult delete(@RequestBody ChatConversationDTO chatConversationDTO) {
        chatConversationDTO.setUserId((String)StpUtil.getLoginId());
        return SaResult.data(chatConversationService.delete(chatConversationDTO));
    }

    /**
     * 修改对话框是否显示
     * @param chatConversationDTO
     * @return
     */
    @PostMapping("/show")
    public SaResult show(@RequestBody ChatConversationDTO chatConversationDTO) {
        chatConversationDTO.setUserId((String)StpUtil.getLoginId());
        return SaResult.data(chatConversationService.show(chatConversationDTO));
    }

    @GetMapping("/all")
    public SaResult getAll() {
        return SaResult.data(chatConversationService.getAll());
    }

}
